﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ComponentFactory.Krypton.Toolkit;
using System.IO;

namespace CompilerControls
{
    public partial class ExportDialog : KryptonForm
    {
        public string FilePath
        {

            get { return textBoxFilePath.Text; }
            
        }

    

        public string Separator
        {
            get { return comboBoxSep.SelectedValue.ToString(); }
           
        }

        public Encoding Encoding
        {
            get { return (Encoding)comboBoxEncoding.SelectedValue; }
            
        }

        public string LineBreak
        {
            get { return kryptonRadioButtonWinLinebreak.Checked ? "\r\n" : "\n"; }
            
        }

        public string PathSeparator
        {
            get { return kryptonRadioButtonWinPath.Checked ? "\\" : "/"; }

        }

        public bool CreateRscript
        {
            get {  return kryptonCheckBoxRScript.Checked; }
        
        }



        private List<KeyValuePair<string, string>> separators;
        private List<KeyValuePair<string, Encoding>> encodings;
        public ExportDialog(string expName)
        {
           
            InitializeComponent();
            separators = new List<KeyValuePair<string, string>>();
            separators.Add(new KeyValuePair<string,string>( "Tabulator (recommended)", "\t"));
            separators.Add(new KeyValuePair<string,string>("Comma", ","));
            separators.Add(new KeyValuePair<string,string>("Semicolon", ";"));
            separators.Add(new KeyValuePair<string,string>("Colon", ":"));



            comboBoxSep.DataSource = separators;
            comboBoxSep.DisplayMember = "Key";
            comboBoxSep.ValueMember = "Value";
            comboBoxSep.SelectedValue = "\t";

            encodings = new List<KeyValuePair<string, Encoding>>();
            encodings.Add(new KeyValuePair<string,Encoding>("ASCII", Encoding.ASCII));
            encodings.Add(new KeyValuePair<string, Encoding>("UTF7", Encoding.UTF7));
            encodings.Add(new KeyValuePair<string, Encoding>("UTF8 (recommended)", Encoding.UTF8));
            encodings.Add(new KeyValuePair<string, Encoding>("UTF32", Encoding.UTF32));

            BindingSource bindingList = new BindingSource(encodings,null);
            comboBoxEncoding.DataSource = encodings;
            comboBoxEncoding.DisplayMember = "Key";
            comboBoxEncoding.ValueMember = "Value";
            comboBoxEncoding.SelectedValue = Encoding.UTF8;
           
            
            
            saveFileDialog.FileName = expName;
            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
 
            
        }



        private void kryptonButton1_Click(object sender, EventArgs e)
        {
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
                textBoxFilePath.Text = saveFileDialog.FileName;
        }

        private void kryptonCheckBoxWindowsLinebreak_CheckedChanged(object sender, EventArgs e)
        {
            kryptonRadioButtonWinPath.Enabled = kryptonCheckBoxRScript.Checked;
            kryptonRadioButtonUnixPath.Enabled = kryptonCheckBoxRScript.Checked;
        }
    }
}
